﻿// 初始化会议管理中所有人员列表
initMemberList(listMemberList);

// 初始化当前会议中的成员列表
initCurrentMeetingMemberList();

// 初始化聊天控制
initChatCtrl();

// 添加成员
var listenerObject:Object = new Object();
listenerObject.click = function() {
	var flag:Boolean = false;
	var object1:Object, object2:Object;
	
	object1 = listMemberList.selectedItems;
	object2 = listCurrentMemberList;
	
	object2.iconField = "icon";
	for (var i:Number = 0; i < object1.length; i++) {
		flag = false;
		// 判断是否已经存在
		for (var j:Number = 0; j < object2.length; j++) {
			if (object1[i].label == object2.getItemAt(j).label) {
				flag = true;
			}
		}
		
		if (!flag) {
			object2.addItem({
							   label: object1[i].label,
							   data: object1[i].data,
							   icon: object1[i].icon
						   });
		}
	}
};
btnApp.addEventListener("click", listenerObject);

// 删除成员
var listenerObject:Object = new Object();
listenerObject.click = function() {
	var object:Object = listCurrentMemberList;
	var arr:Array = new Array();
	
	// 判断是否选中
	if (object.selectedIndices != undefined) {
		arr = object.selectedIndices;
		
		for (var i:Number = arr.length - 1; i >= 0; i--) {
			// 判断是否为创建者
			if (object.getItemAt(arr[i]).label == currentInfo.data.createUser) {
				alert("系统提示：", "不能删除创建者！", 1);
			} else {
				object.removeItemAt(arr[i]);
			}
		}
	}
};
btnDel.addEventListener("click", listenerObject);

// 保存设置
var listenerObject:Object = new Object();
listenerObject.click = function() {
	var newMemberList:String = "";
	var allowPrivateChat:Boolean = false;
	var showAll:Boolean = false;
	var str:String = "";
	
	// 获取当前会议新的成员列表
	var object:Object = listCurrentMemberList;
	for (var i = 0; i < object.length; i++) {
		newMemberList += object.getItemAt(i).label + ":" + object.getItemAt(i).data + ",";
		str += object.getItemAt(i).label + ",";
	}
	
	nc.call("updateVideoList", null, str);
	nc.call("updateMeeting", null, newMemberList);
	nc.call("setChatMode", null, chkboxChat.selected);
	nc.call("setShowAll", null, chkboxShowAll.selected);
	
	winManagePanel.deletePopUp();
	trace("管理面板已经关闭...");
};
btnOk.addEventListener("click", listenerObject);

// 取消设置
var listenerObject:Object = new Object();
listenerObject.click = function() {
	winManagePanel.deletePopUp();
	trace("管理面板已经关闭...");
};
btnCancel.addEventListener("click", listenerObject);